package com.seeyon.apps.seepkk.form.workflowevent;

import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.seeyon.apps.kk.form.workflowevent.KkBaseExtendPlug;
import com.seeyon.apps.seepkk.manager.SeepManager;
import com.seeyon.cap4.form.bean.FormBean;
import com.seeyon.cap4.form.bean.FormDataMasterBean;
import com.seeyon.cap4.form.bean.FormTableBean;
import com.seeyon.ctp.common.constants.ApplicationCategoryEnum;
import com.seeyon.ctp.workflow.event.WorkflowEventData;
import com.seeyon.ctp.workflow.event.WorkflowEventResult;
public class SeepMemberKkExtendPlug extends KkBaseExtendPlug {
	private static final Log log = LogFactory.getLog(SeepMemberKkExtendPlug.class);
	private SeepManager seepManager;


	@Override
	public String getId() {
		// TODO Auto-generated method stub
		return "seepMemberKkExtendPlug";
	}

	@Override
	public String getLabel() {
		// TODO Auto-generated method stub
		return "Seep模块参会者重复校验";
	}

	public ApplicationCategoryEnum getAppName() {
		return ApplicationCategoryEnum.form;
	}

	
	
	// 发起前事件
	public WorkflowEventResult onBeforeStart(WorkflowEventData data) {
		WorkflowEventResult result = new WorkflowEventResult();
		Map<String, Object> formdata = data.getBusinessData();
		FormBean formBean = (FormBean) data.getBusinessData().get("formBean");
		FormDataMasterBean formDataMasterBean = (FormDataMasterBean) data.getBusinessData().get("formDataBean");
		FormTableBean formData = formDataMasterBean.getFormTable();// 获取表单bean对象
		//参会者提名人员重复校验
		String resultMsg=this.seepManager.membersCheck(formdata);
		if(!"".equals(resultMsg)){
			result.setAlertMessage(resultMsg);
			return result;
		}
		//医生状态校验
		String resultMsg2=this.seepManager.membersStateCheck(formdata);
		if(!"".equals(resultMsg2)){
			result.setAlertMessage(resultMsg);
			return result;
		}
		return null;
	}

	public SeepManager getSeepManager() {
		return seepManager;
	}

	public void setSeepManager(SeepManager seepManager) {
		this.seepManager = seepManager;
	}
	
	
}
